package top.zackyoung.druid.simple.controller;

import com.alibaba.druid.stat.DruidStatManagerFacade;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import top.zackyoung.druid.simple.service.UserService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ZackYoung
 * @version 1.0
 * @date 2021/9/28
 */
@RestController
public class DruidStatController {
    @Resource
    UserService userService;

    @GetMapping("/druid/stat")
    public Object druidStat() {
        return DruidStatManagerFacade.getInstance().getDataSourceStatDataList();
    }

    @GetMapping("/master")
    public Object getUsers() {
        return userService.getUsers();
    }

    @GetMapping("/salve1/{id}")
    public Object getUsers(@PathVariable("id") Long userId) {
        return userService.getUserById(userId);
    }
}
